package com.lazybones.base.engineer.mapper.test;

import com.lazybones.base.engineer.entity.test.Test1Entity;
import com.lazybones.base.engineer.entity.test.TestEntity;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;

import java.util.List;

public interface ITestMapper extends BaseMapper<TestEntity> {
    /**
     * left join 写法
     * @param id
     * @return
     */
    default List<TestEntity> selectById(int id){
        QueryCondition qc = QueryCondition.create("system_file","test","id","=",id);
        QueryWrapper qw =  QueryWrapper.create().select().from("test").as("t").leftJoin("test1").as("t1")
                .on(TestEntity::getTid,Test1Entity::getId).where(qc);
        return selectListByQuery(qw);
    }

    default List<TestEntity> selectOtherById(int id){
        QueryCondition qc = QueryCondition.create("system_file","test","id","=",id);
        QueryWrapper qw =  QueryWrapper.create().select().from("test").as("t").leftJoin("test1").as("t1")
                .on(TestEntity::getTid,Test1Entity::getId).where(qc);
        return selectListByQueryAs(qw, TestEntity.class);
    }
}
